package com.pactera.controller.common.web;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;
/**
 * 
 * 类名称：GlobalExceptionHandler
 * 类描述：捕捉异常
 * 创建人：yyd
 * 创建时间：2018年9月21日 下午5:33:54
 * @version 1.0.0
 */
@ControllerAdvice
public class GlobalExceptionHandler {

	Logger logger =LoggerFactory.getLogger(GlobalExceptionHandler.class);
	
    @ExceptionHandler(value = Exception.class)
    public ModelAndView defaultErrorHandler(HttpServletRequest req,Exception e){
	   	String path = req.getRequestURL().toString();
	   	try {
   			logger.error("全局异常控制",e);
//   			errorLogService.saveErrorLog(userSessionVo, path, e,Constants.LOG_SOURCE_ADMIN,req);
		} catch (Exception e2) {
			logger.error("ErrorLog 写入异常",e2);
		}
   		return  new ModelAndView("error/500");
    }
}
